﻿<div class="top-row pl-4 navbar navbar-dark">
    <a class="navbar-brand" href="">BlazorElectronTemplate</a>
    <button class="navbar-toggler" @onclick="ToggleNavMenu">
        <span class="navbar-toggler-icon"></span>
    </button>
</div>

<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
    <ul class="nav flex-column">
        <li class="nav-item px-3">
            <NavLink class="nav-link" href="@home.Href" @onclick="()=>AddCommponents(home)" Match="NavLinkMatch.All">
                <span class="oi oi-@home.Icon" aria-hidden="true"></span>@home.Name
            </NavLink>
        </li>
        <li class="nav-item px-3">
            <NavLink class="nav-link" href="@counter.Href" @onclick="()=>AddCommponents(counter)">
                <span class="oi oi-@counter.Icon" aria-hidden="true"></span>@counter.Name
            </NavLink>
        </li>
        <li class="nav-item px-3">
            <NavLink class="nav-link" href="@fetchdata.Href" @onclick="()=>AddCommponents(fetchdata)">
                <span class="oi oi-@fetchdata.Icon" aria-hidden="true"></span> @fetchdata.Name
            </NavLink>
        </li>
    </ul>
</div>

@using Components;
@inject Data.TabContainer ContainerTab;
@code {
    private bool collapseNavMenu = true;
    private TabClass fetchdata = new TabClass { Href="fetchdata",Icon="list-rich",Name="Fetch data" };
    private TabClass counter = new TabClass { Href = "counter", Icon = "plus", Name = "Counter" };
    private TabClass home = new TabClass { Href = "", Icon = "home", Name = "Home" };

    private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;

    private void ToggleNavMenu()
    {
        collapseNavMenu = !collapseNavMenu;
    }
    private void AddCommponents(TabClass str)
    {
        if (!ContainerTab.TabList.Contains(str))
        {
            var listnavlink = ContainerTab.TabList;
            listnavlink.Add(str);
            ContainerTab.TabList = listnavlink;
        }
    }
    public void SetListNavlink(List<TabClass> listnavlink)
    {
        
    }
}
